package model.service;

import java.util.List;
import vo.AdminVO;
import vo.ListVO;
import vo.PagingBean;

import model.dao.AdminDAO;

public class AdminService {
	
	private static AdminService instance=new AdminService();
	
	private AdminDAO dao;
	
	private AdminService(){
		dao=AdminDAO.getinstance();		
	}
	
	public static AdminService getInstance(){
		if(instance==null) instance=new AdminService();
		return instance;
	}
	
	public ListVO selectAllMember(int pageNo) throws Exception{
		
		ListVO lvo=null;
				
		List list=dao.selectAllMember(pageNo);		
		int totalCount=dao.selectAllCount();	
		
		PagingBean pb=new PagingBean(totalCount, pageNo);
		lvo=new ListVO(list, pb);
			
		return lvo;
	}
		
	public AdminVO selectById(String id) throws Exception{		
		AdminVO avo=dao.selectById(id);
		avo.setCountProduct(dao.selectCountProduct(id));
		avo.setCountVendor(dao.selectCountVendor(id));
		avo.setCountCustomer(dao.selectCountCustomer(id));
		avo.setCountStock(dao.selectCountStock(id));
		avo.setCountSale(dao.selectCountSale(id));				
		return avo;
	}	
	
	public int update(String id)throws Exception{
		int count=dao.update(id);
		return count;
	}
	
}
